package com.test.mybatis.entities;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2018/11/21 14:04
 * <p>
 * 希望数据库保存的是状态码
 */
public enum EmpStatus {
    //用户登陆
    LOGIN(100, "用户登陆"),
    //用户登出
    LOGOUT(200, "用户登出"),
    //用户不存在
    REMOVE(300, "用户不存在");

    private Integer code;
    private String msg;

    EmpStatus(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    /**
     * 按照状态码返回枚举对象
     *
     * @param code
     * @return
     */
    public static EmpStatus getEmpStatusByCode(int code) {
        if (code == 100) {
            return LOGIN;
        } else if (code == 200) {
            return LOGOUT;
        } else {
            return REMOVE;
        }
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
